﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Common Core Extensions
//===============================================================================

using System;
using System.Reflection;
using System.Diagnostics.CodeAnalysis;

namespace EntLibContrib.Common.Configuration.Design.Editors
{
	/// <summary>
	/// Indicates the method filter for the property that this attribute decorates.
	/// </summary>
	/// <remarks>This attribute is used with the <see cref="MethodSelectorEditor"/> to filter the methods returned</remarks>
  [AttributeUsage(AttributeTargets.Property, AllowMultiple=false)]
  public sealed class MethodFilterAttribute : Attribute
	{
		#region Fields
		private readonly BindingFlags bindingFlags;
		#endregion

		#region Properties
		/// <summary>
		/// Gets the binding flags for the method selector.
		/// </summary>
		/// <value>
		/// The binding flags for the method selector.
		/// </value>
		[SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")]
		public BindingFlags BindingFlags
		{
			get { return bindingFlags; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initializes a new instance of the  <see cref="MethodFilterAttribute"/> class.
		/// </summary>
		public MethodFilterAttribute()
			: this(BindingFlags.Default)
		{
		}

		/// <summary>
		/// Initializes a new instance of the  <see cref="MethodFilterAttribute"/> class.
		/// </summary>
		/// <param name="bindingFlags">The binding flags.</param>
		/// <remarks>To set more than one binding flag use the OR operator '|'</remarks>
		[SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")]
		public MethodFilterAttribute(BindingFlags bindingFlags)
			: base()
		{
			this.bindingFlags = bindingFlags;
		}
		#endregion
	}
}
